package com.tencent.sr.iris.activity.restapi.activity;

import com.tencent.sr.iris.activity.interfaces.client.activity.ActivityConfigClient;
import com.tencent.sr.iris.activity.interfaces.request.IrisPaginationRequest;
import com.tencent.sr.iris.activity.interfaces.request.acticity.*;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityAwardInfoResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityMonthLimitResponse;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityUidLimitResponse;
import com.tencent.sr.iris.activity.service.activity.impl.IrisActivityConfigService;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 任务参与记录
 *
 * @author nixiaolin
 * @date 2023/2/15 18:02
 */
@Api(tags = "任务参与记录", value = "任务参与记录相关接口")
@RestController
@RequestMapping(value = {"/api/v1/iris/iris-activity-core-service/activity/config"})
public class ActivityConfigController implements ActivityConfigClient {

    @Resource
    private IrisActivityConfigService activityConfigService;

    /**
     * 查询月份限额列表
     *
     * @author nixiaolin
     */
    @Override
    public HttpResult<PaginationResponse<ActivityMonthLimitResponse>> monthLimitConfigPage(
            @Validated @RequestBody PaginationRequest request) {
        PaginationResponse<ActivityMonthLimitResponse> response = activityConfigService.monthLimitConfigPage(request);
        return HttpResult.succ(response);
    }

    /**
     * 查询uid限额列表
     *
     * @author nixiaolin
     */
    @Override
    public HttpResult<PaginationResponse<ActivityUidLimitResponse>> uidLimitConfigPage(
            @Validated @RequestBody IrisPaginationRequest<ActivityUidLimitPageRequest> request) {
        PaginationResponse<ActivityUidLimitResponse> response = activityConfigService.uidLimitConfigPage(request);
        return HttpResult.succ(response);
    }

    /**
     * 新增当月配置
     *
     * @author nixiaolin
     */
    @Override
    public HttpResult<Boolean> addCurrentMonthLimit(
            @Validated @RequestBody ActivityMonthLimitAddRequest request) {
        Boolean response = activityConfigService.addCurrentMonthLimit(request);
        return HttpResult.succ(response);
    }

    /**
     * 新增uid配置
     *
     * @author nixiaolin
     */
    @Override
    public HttpResult<Boolean> addUidLimit(
            @Validated @RequestBody ActivityUidLimitAddRequest request) {
        Boolean response = activityConfigService.addUidLimit(request);
        return HttpResult.succ(response);
    }

    /**
     * 更新uid配置
     *
     * @author nixiaolin
     */
    @Override
    public HttpResult<Boolean> updateUidLimit(
            @Validated @RequestBody ActivityUidLimitUpdateRequest request) {
        Boolean response = activityConfigService.updateUidLimit(request);
        return HttpResult.succ(response);
    }

    /**
     * 查询活动奖励配置金额
     * @param request
     * @return
     */
    @Override
    public HttpResult<ActivityAwardInfoResponse> getConfigAwardInfo(GetActivityConfigAwardRequest request) {
        ActivityAwardInfoResponse response = activityConfigService.getConfigAwardInfo(request);
        return HttpResult.succ(response);
    }
}
